<!--{template header}-->


<script language="javascript" src="image/editor/editor_function.js"></script>
<script language="javascript" src="source/script_blog.js"></script>
<script type="text/javascript">
function insertImage(text) {
	//text = "\n[img]" + text + "[/img]\n";
	insertContent('images', text)
}

function edit_album_show(id) {
	var obj = $('uchome-edit-'+id);
	if(obj.style.display == '') {
		obj.style.display = 'none';
	} else {
		obj.style.display = '';
	}
}
function validate(obj) {
    var subject = $('mname');
    if (subject) {
    	var slen = strlen(subject.value);
        if (slen < 1 || slen > 50) {
            alert("片名长度(1~50字符)不符合要求");
            subject.focus();
            return false;
        }
    }
    if ($('typeid').value == '0') {
        alert("请选择分类");
        $('typeid').focus();
        return false;
    }
    if ($('regionid').value == '0') {
        alert("请选择区域分类");
        $('regionid').focus();
        return false;
    }
    if ($('movieurl').value == '') {
        alert("请填写播放地址");
        $('movieurl').focus();
        return false;
    }
   if ($('playid').value == '0') {
        alert("请选择使用的播放器");
        $('playid').focus();
        return false;
    }
    if (strlen($('message').value) < 10 || strlen($('message').value) > 1500) {
        //alert("介绍长度(10~1500字符)不符合要求");
        //$('message').focus();
        //return false;
    }
    return true;
    
    
}

//本地化
var xxmlHttp;
function ajaxFunction(){
	//var xxmlHttp;
	try{
		// Firefox, Opera 8.0+, Safari
		xxmlHttp=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xxmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				alert("您的浏览器不支持AJAX！");
				return false;
			}
		}
	}
}


function localimage(obj){
	ajaxFunction();
	if(obj==undefined){
		var imgurl = document.getElementById('images').value
	}else{
		var imgurl = obj.value;
	}
	//alert(imgurl.indexOf('http://'));return false;
	if(imgurl.indexOf('http://') == 0){
	}else{
		alert('此图片不用本地化');return false;
	}
	var url='./cp.php?ac=movie&op=localimage&randdomid='+Math.random();
	xxmlHttp.open('POST',url,true);
	xxmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xxmlHttp.onreadystatechange = handelChange;//这一句最为关键，是ajax异步通讯的关键点
	formElements='images='+document.getElementById('images').value;
	//alert(formElements);exit();
	xxmlHttp.send(formElements);		
	//xxmlHttp.send(null);
}
function handelChange(){
	var image=document.getElementById("images");
	if(xxmlHttp.readyState == 4 && xxmlHttp.status == 200){
		var Strings = xxmlHttp.responseText;
		image.value = Strings;
		alert('本地化成功');
	}else{
		//alert('本地化失败');
	}
	
}
</script>
<!--{if $topic}-->
	<!--{template cp_topic_menu}-->
<!--{else}-->
	<h2 class="title"><img src="image/app/supev.gif" />影视发布</h2>
	<div class="tabs_header">
		<ul class="tabs">
			<!--{if $movie[movieid]}-->
			<li class="active"><a href="cp.php?ac=movie&moveid=$movie[movieid]"><span>编辑影视</span></a></li>
			<!--{/if}-->
			<li<!--{if empty($movie[movieid])}--> class="active"<!--{/if}-->><a href="cp.php?ac=movie"><span>发布新影视</span></a></li>
			<li><a href="space.php?do=movie&view=me"><span>返回影视基地</span></a></li>
		</ul>
	</div>
<!--{/if}-->

<div class="c_form">

	<style type="text/css">
		.userData {behavior:url(#default#userdata);}
	</style>


	<form method="post" action="cp.php?ac=movie&movieid=$movie[movieid]" enctype="multipart/form-data">
		<table cellspacing="4" cellpadding="4" width="100%" class="infotable">
			<tr>
				<td>
				影片名称：<input type="text" class="t_input" id="mname" name="mname" value="$movie[mname]" size="50"/>
				</td>
			</tr>
			<tr>
				<td>
				影片分类：<select name="typeid" id="typeid">
						<option value="0">选择分类</option>
						<!--{loop $typelist $value}-->
						<!--{if $value['typeid'] == $movie[typeid]}-->
						<option value="$value[typeid]" selected>$value[typename]</option>
						<!--{else}-->
						<option value="$value[typeid]">$value[typename]</option>
						<!--{/if}-->
						<!--{/loop}-->
					</select>
					<select name="regionid" id="regionid">
						<option value="0">选择地区</option>
						<!--{loop $regionlist $value}-->
						<!--{if $value['regionid'] == $movie[regionid]}-->
						<option value="$value[regionid]" selected>$value[regionname]</option>
						<!--{else}-->
						<option value="$value[regionid]">$value[regionname]</option>
						<!--{/if}-->
						<!--{/loop}-->
					</select>
				</td>
			</tr>
			<tr>
				<td>
				图　　片：<input type="text" class="t_input" id="images" name="images" value="$movie[images]" size="50" />
					<input type="checkbox" name="localimage" value="1" checked />图片本地化
					<!--{if !$_SGLOBAL[inajax] && (!$movie['uid'] || $movie['uid']==$_SGLOBAL['supe_uid'])}-->
						<input type="button" name="clickbutton[]" value="插入图片" class="button" onclick="edit_album_show('album')"> 上传新图请到相册<a href="cp.php?ac=upload" target="_blank">上传</a>
					<!--{/if}--><br/>
					<table cellspacing="4" cellpadding="4" width="100%" class="infotable" id="uchome-edit-album" style="display:none;">
						<tr>
							<th width="100">&nbsp;</th>
							<td>
								选择相册: <select name="view_albumid" onchange="picView(this.value)">
									<option value="none">选择一个相册</option>
									<option value="0">默认相册</option>
									<!--{loop $albums $value}-->
									<option value="$value[albumid]">$value[albumname]</option>
									<!--{/loop}-->
								</select> (点击图片可以插入到内容中)
								<div id="albumpic_body"></div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			
			<tr>
				<td>
				主　　演：<input type="text" class="t_input" id="actor" name="actor" value="$movie[actor]" size="60"/>
				</td>
			</tr>
			<tr>
				<td>
				影片介绍：<br> 
				<textarea name="message" id="uchome-ttHtmlEditor" style="border: 1px solid #C5C5C5; height:400px;width:100%;">$movie[desrcipt]</textarea>
				</td>
			</tr>
			<tr>
				<td>
				标　　签：<input type="text" class="t_input" id="attribute" name="attribute" value="$movie[attribute]" size="60"/>
				</td>
			</tr>
			<tr>
				<td>
				默认资源：<select name="playid" id="playid">
						<option value="0">选择资源类型</option>
						<!--{loop $playlist $value}-->
						<!--{if $value['playid'] == $movie[playid]}-->
						<option value="$value[playid]" selected>$value[playername]</option>
						<!--{else}-->
						<option value="$value[playid]">$value[playername]</option>
						<!--{/if}-->
						<!--{/loop}-->
					</select>
				</td>
			</tr>
			<tr>
				<td>
				<textarea name="movieurl" id="movieurl" cols="85" rows="8">$movie[movieurl]</textarea>
				</td>
			</tr>
		</table>
		<input type="hidden" name="moviesubmit" value="true" />
		<input type="hidden" name="movieid" value="$movie[movieid]" />
		<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
		<table cellspacing="4" cellpadding="4" width="100%" class="infotable">
			<tr>
				<th width="100">&nbsp;</th>
				<td>
				<!--{if checkperm('managemovie')}-->
				是否直接发布
				<input type="checkbox" id="check" name="check" value="1" checked/>&nbsp;&nbsp;&nbsp;
				<!--{/if}-->
				<input type="submit" id="moviebutton" name="moviebutton" value="保存发布" onclick="return validate(this);"  class="submit" /></td>
			</tr>
		</table>
	</form>

	
	
</div>

<!--{template footer}-->